<?php
/*
	我的足迹
*/
defined('BY_JYA') or exit('error');
$this->model('member')->checklogin();
$return['ice_menu_array']=array( array('menu_key' => 'index', 'menu_name' => '更换绑定', 'menu_url' => custom_url('jy_weishop/member.bind/',true)) );
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('basic');
	$return['list']=array();
	$return['member']=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	set_html('title','更换绑定');
	exi($return);
}
if($_RQ['op']=='sendcode'){
	$post=get_postdata();
	$mobile=$post['mobile'];
	$code=rand(1000,9999);
	$_SESSION['smscode']=$code;
	$content=array('code'=>$code);
	$setting=uni_setting('member_setting');
	$mid=$setting['sms_mb']['login'];
	$result=cfc('jy_alisms')->send($mobile,$content,$mid);
	if($result){
		exi('success');
	}else{
		exi('error');
	}

}
if($_RQ['op']=='post'){
	$post=get_postdata();
	if(!check_sms_code($post['verifycode'])){
		exi('手机验证码错误！','error');
	}
	pdo_update('core_members',array('mobile'=>intval($post['mobile'])),array('id'=>$_SESSION['uid']));
	exi('绑定成功','','/member.info/');
}